//
//  YPGlobal.swift
//  YourPassword
//
//  Created by 李冲 on 15/11/25.
//  Copyright © 2015年 Saye. All rights reserved.
//

import UIKit

enum YPThemeStyle {
    case Default
}

struct YPGlobal {
    static let passwordConfigKey = "passwordConfig"
    private static var themeStyle: YPThemeStyle = .Default
    static func passwordConfig() -> YPPasswordConfig {
        let userDefaults = NSUserDefaults.standardUserDefaults()
        if let dict = userDefaults.objectForKey(passwordConfigKey) as? NSDictionary {
            return YPPasswordConfig(dictionary: dict)
        }
        else {
            let config = YPPasswordConfig()
            setPasswordConfig(config)
            return config
        }
    }
    
    static func setPasswordConfig(config: YPPasswordConfig) {
        let userDefaults = NSUserDefaults.standardUserDefaults()
        userDefaults.setObject(config.dictionary(), forKey: passwordConfigKey)
    }
    
    static func setThemeStyle(style: YPThemeStyle) {
        themeStyle = style
    }
    static func applyTheme(viewController: UIViewController) {
        viewController.setThemeUsingPrimaryColor(UIColor.flatBlueColor(), withSecondaryColor: UIColor.flatLimeColor(), andContentStyle: .Contrast)
    }
}